﻿using L.EntityFramework;
using NB.MGJ.FrameWork;
using NB.MGJ.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NB.MGJ.Service.AntiFake {
public class ReplyPseudoCodeService :BaseService{
	public BaseRepository _base= new BaseRepository();
    private BaseRepository<L.EntityModel.EntityContext> baserRepository2;
    public ReplyPseudoCodeService()
    {
        baserRepository2 = CreateBaseRepository<L.EntityModel.EntityContext>();
    }

	#region 修改
    public int EditReplyPseudoCodeService(L.EntityModel.AntiFake_QueryReply model)
    {
        return baserRepository2.Update<L.EntityModel.AntiFake_QueryReply>(model);
    }

	#endregion

	#region  ID获取
    public L.EntityModel.AntiFake_QueryReply GetQueryReplyByID(int id)
    {
        return baserRepository2.SearchFirstOrDefault<L.EntityModel.AntiFake_QueryReply>(p => p.EnterpriseId == id);
        
    }
	#endregion
    public int GetQueryReplyCount(int EnterpriseId)
    {
        string sql = string.Format(" select count(*) from AntiFake_QueryReply where EnterpriseId={0}", EnterpriseId);
		return Convert.ToInt32(_base.GetSingle(sql));
	}

    public int UpdateReplyPseudo(L.EntityModel.AntiFake_QueryReply model)
    {
        string sql = " select * from AntiFake_QueryReply ";
        var re = baserRepository2.SearchFirstOrDefault<L.EntityModel.AntiFake_QueryReply>(sql);
        model.ID = re.ID;
        int rulset = baserRepository2.Update<L.EntityModel.AntiFake_QueryReply>(model);
		return rulset;
	}
	#region  添加
    public int AddReplyPseudo(L.EntityModel.AntiFake_QueryReply model)
    {
        baserRepository2.Insert<L.EntityModel.AntiFake_QueryReply>(model);
        return model.ID;
       
    }
	#endregion
	public bool IsExistsByID(int id) {
		string sql = string.Format("select * from AntiFake_QueryReply where EnterpriseId={0}", id);
		return _base.dataExists(sql);
	}
	}
}
                         